<style>
.table-bordered > thead > tr > th, .table-bordered > thead > tr > td {

    white-space: nowrap;
    text-align: center;
    vertical-align: middle!important;
}
.table-bordered > thead > tr > th, .table-bordered > tbody > tr > th, .table-bordered > tfoot > tr > th, .table-bordered > thead > tr > td, .table-bordered > tbody > tr > td, .table-bordered > tfoot > tr > td {
     white-space: nowrap;
	text-align: center;
    vertical-align: middle!important;
	    border: 1px solid #ddd;
}
.fixed-table-body{
	
}
</style>
<?php if(AdminAuth('finance/extract/week/analysis_view') && !empty($WeekInfo[$key]['all'])){?>
<div class=" panel panel-default pull-left" style="width: 70%;">
	<div class="panel-heading">
        <h3 class="panel-title">
            提成详情表
        </h3>
    </div>
	<div class="fixed-table-body panel-body">
	<table  class="table table-bordered table-hover" width="100%">
		   <thead>
				<tr>
					 <th rowspan="2"><?php echo __('Id');?></th>
					 <th rowspan="2"><?php echo __('Season.Season_time');?></th>
					 <th rowspan="2"><?php echo __('Address');?></th>
					 <th rowspan="2"><?php echo __('Season.Lecturer_id');?></th>
					 <th rowspan="2"><?php echo __('Season.Subject_id');?></th>
					 <th rowspan="2"><?php echo __('Data.num');?></th>
					 <th rowspan="2"><?php echo __('School.People_num');?></th>
					 <th rowspan="2"><?php echo __('School.School_id');?></th>
					 <th rowspan="2"><?php echo __('School.Type');?></th>
					 <th colspan="<?php echo count($WeekInfo[$key]['sales_price'])+1;?>"><?php echo __('销售金额');?></th>
					 <th rowspan="2"><?php echo __('按场次金额');?></th>
					 <th rowspan="2"><?php echo __('手边题本数量');?></th>
					 <th rowspan="2"><?php echo __('手边题本单科成本');?></th>
					 <th rowspan="2"><?php echo __('手边题本总金额');?></th>
					 <th rowspan="2"><?php echo __('扣除成本后金额');?></th>
					 <th rowspan="2"><?php echo __('扣除成本后按场次金额');?></th>
					 <th rowspan="2"><?php echo __('2986折合');?></th>
					 <th rowspan="2"><?php echo __('3686折合');?></th>
					 <th rowspan="2"><?php echo __('外联单场提成标准');?></th>

					 <th rowspan="2"><?php echo __('单套折合');?></th>
					 <th rowspan="2"><?php echo __('外联提成');?></th>
					 <th rowspan="2"><?php echo __('外联姓名');?></th>
					 
					 <th rowspan="2"><?php echo __('管理提成标准');?></th>
					 <th rowspan="2"><?php echo __('管理提成金额');?></th>
				</tr>
				<tr>
				<?php if(!empty($WeekInfo[$key]['sales_price'])){?>
					<?php foreach($WeekInfo[$key]['sales_price'] as $ks=>$vs){?>
							<th><?php echo $ks;?></th>
					<?php }?>
			    <?php }?>
					<th><?php echo __('销售金额');?></th>
				</tr>
		   </thead>
		   <tbody>
		
				<?php foreach($WeekInfo[$key]['all'] as $kk=>$vv){?>
						<?php
						if(empty($vv['school'])) continue;
						$count = count($vv['school']);
						 $i = 1;
						?>
						<?php foreach($vv['school'] as $k=>$v){ ?>
						<tr>
							<?php if($i == 1){ ?>
								<td rowspan="<?php echo $count?>"><?php echo $kk;?></td>
								<td rowspan="<?php echo $count?>"><?php echo $vv['season_time'];?></td>
								<td rowspan="<?php echo $count?>"><?php echo $vv['address'];?></td>
								<td rowspan="<?php echo $count?>"><?php echo $vv['lecturer_name'];?></td>
								<td rowspan="<?php echo $count?>"><?php echo $vv['subject_name'];?></td>
								<td rowspan="<?php echo $count?>"><?php echo $vv['price_num'];?></td>
								<td rowspan="<?php echo $count?>"><?php echo $vv['people_numTotal'];?></td>
							<?php }?>
								<td><?php echo $v['school_name'] ?? '';?></td>
								<td><?php echo  isset($v['type'])? __('School.Type '.$v['type'].''):'';?></td>
					
								<?php if(!empty($WeekInfo[$key]['sales_price'])){?>
									<?php foreach($WeekInfo[$key]['sales_price'] as $ks=>$vs){ ?>
										<td><?php echo $v['price_info'][$ks] ??0;?></td>
									<?php }?>
								<?php }?>
								<td><?php echo $v['price_total'] ?? 0; ?></td>
							<?php if($i == 1){ ?>
								<td rowspan="<?php echo $count?>"><?php echo $vv['price_total'];?></td>
							<?php }?>

								<td><?php echo $v['book_num'] ?? 0; ?></td>
								<td><?php echo $v['book_price'] ?? 0; ?></td>
								<td><?php echo $v['book_priceTotal'] ?? 0; ?></td>
								<td><?php echo $v['sales_priceTotal'] ?? 0; ?></td>
							<?php if($i == 1){ ?>
								
								<td rowspan="<?php echo $count?>"><?php echo $vv['sales_priceTotal'];?></td>
								<td rowspan="<?php echo $count?>"><?php echo $vv['into_29'];?></td>
								<td rowspan="<?php echo $count?>"><?php echo $vv['into_36'];?></td>
								<td rowspan="<?php echo $count?>"><?php echo $vv['OutreachExtract'];?></td>
							<?php }?>
								<td><?php echo $v['into_one'] ?? 0; ?></td>
								<td><?php echo $v['OutreachExtract'] ?? 0; ?></td>
								<td>
									<?php if(!empty($v['userid_info'])){?>
											<?php foreach($v['userid_info'] as $ks=>$vs){ ?>
												<?php echo $vs['name'],'-',$vs['value'];?>
											<?php }?>
									<?php }?>
								</td>
							<?php if($i == 1){ ?>
								
								<td rowspan="<?php echo $count?>"><?php echo $vv['ManageExtract']??0;?></td>
								<td rowspan="<?php echo $count?>"><?php echo $vv['ManageExtractPrice']??0;?></td>
							<?php }?>
							<?php 
								$i++;
								unset($k,$v);
							?>
						</tr>
						<?php 
							}
							unset($kk,$vv,$i);
						?>
					
				 <?php }?>
		
			 <tr >
					<td colspan="5">合计</td>
					<td><?php echo $WeekInfo[$key]['total']['price_num']?></td>
					<td><?php echo $WeekInfo[$key]['total']['people_numTotal']?></td>
					<td></td>
					<td></td>
					<?php if(!empty($WeekInfo[$key]['sales_price'])){?>
						<?php foreach($WeekInfo[$key]['sales_price'] as $ks=>$vs){ ?>
							<td><?php echo $vs;?></td>
						<?php }?>
					<?php }?>
					<td><?php echo $WeekInfo[$key]['total']['price_total']?></td>
					<td><?php echo $WeekInfo[$key]['total']['price_total']?></td>
					<td><?php echo $WeekInfo[$key]['total']['book_numTotal']?></td>
					<td><?php echo $WeekInfo[$key]['total']['book_price']?></td>
					<td><?php echo $WeekInfo[$key]['total']['book_priceTotal']?></td>
					<td><?php echo $WeekInfo[$key]['total']['sales_priceTotal']?></td>
					<td><?php echo $WeekInfo[$key]['total']['sales_priceTotal']?></td>
					<td></td>
					<td><?php echo $WeekInfo[$key]['total']['into_36']?></td>
					<td></td>
					<td><?php echo $WeekInfo[$key]['total']['into_one']?></td>
					<td><?php echo $WeekInfo[$key]['total']['OutreachExtractPirce']?></td>
					<td></td>
					<td></td>
					<td><?php echo $WeekInfo[$key]['total']['ManageExtractPrice']?></td>
			 </tr>
		   </tbody>
		
	</table>
	</div>
</div>
<?php }?>
<?php if(AdminAuth('finance/extract/week/analysis_royalty') && !empty($WeekInfo['UserExtract']['User'])){?>
<div class="panel panel-default pull-right " style="width: 29%;">
	<div class="panel-heading">
        <h3 class="panel-title">
            提成表
            <span class="pull-right">
			<a href="javascript:;"  <?php if($row['status'] == 1 || $row['status'] == 4){?> onclick="add(<?php echo $id;?>,'<?php echo $key;?>')" title="点击修改" <?php }?>>无票金额： <?php echo $WeekInfo['UserExtract']['Total']['no_ticketPrice'] ?? 0;?></a>
			无票扣发：<?php echo $WeekInfo['UserExtract']['Total']['no_ticket'] ?? 0;?>
			</span>
        </h3>
    </div>
	<div class="fixed-table-body panel-body">
	<table  class="table table-bordered table-hover" width="100%">
		   <thead>
		        <tr>
					<th>岗位</th>
					<th>姓名</th>
					<th>提成类型</th>
					<th>提成金额</th>
					<th>合计</th>
					<th>无票扣发</th>
				</tr>
				
		   </thead>
		   <tbody>
		   <?php foreach($WeekInfo['UserExtract']['User'] as $kk=>$vv){?>
				  <?php $i = 1;?>
				 <?php foreach($vv['extract'] as $k=>$v){?>
				   <tr>
					  <?php if($i == 1){ ?>
						<td rowspan="<?php echo $vv['count'];?>"><?php echo $vv['position_text'];?></td>
						<td rowspan="<?php echo $vv['count'];?>"><?php echo $vv['username_text'];?></td>
					  <?php }?>
						 <td><?php echo $v['title'];?></td>
						 <td><?php echo $v['price'];?></td>
					  <?php if($i == 1){ ?>
						<td rowspan="<?php echo $vv['count'];?>"><?php echo $vv['week_total'];?></td>
						<td rowspan="<?php echo $vv['count'];?>"><?php echo $vv['no_ticket_total'];?></td>
					  <?php }?>
					  <?php $i++;?>
				   </tr>
				<?php }?>
			<?php }?>
			  <tr>
				<td colspan="3">合计</td>
				<td><?php echo $WeekInfo['UserExtract']['Total']['week_total'] ?? 0;?></td>
				<td><?php echo $WeekInfo['UserExtract']['Total']['week_total'] ?? 0;?></td>
				<td><?php echo $WeekInfo['UserExtract']['Total']['no_ticket_total'] ?? 0;?></td>
				
			  </tr>
		   </tbody>
		
	</table>
	</div>
</div>

<?php }?>
<?php if(AdminAuth('finance/extract/week/analysis_fee') && !empty($WeekInfo[$key]['books'])){?>
<div class=" panel panel-default" style="width: 70%;">
	<div class="panel-heading">
        <h3 class="panel-title">
            费用表
        </h3>
    </div>
	<div class="fixed-table-body panel-body">
	<table  class="table table-bordered table-hover" width="100%">
		   <thead>
		        <tr>
					<th colspan="25">分公司财务填写</th>
					<th colspan="12">总公司财务填写</th>
					<th colspan="2">成本</th>
					<th colspan="5">复合填写</th>
					<th rowspan="2">销售利润</th>
					<th rowspan="2">单场费用</th>
					<th rowspan="2">单套费用</th>
				</tr>
				<tr>
				<?php foreach($WeekInfo[$key]['books'] as $kk=>$vv){?>
					<?php if($vv['type'] == 1){ ?>
					 <th><?php echo $vv['name'];?></th>
					 <?php }?>
				 <?php }?>	
				 <th>费用小计</th>
				<?php foreach($WeekInfo[$key]['books'] as $kk=>$vv){?>
					<?php if($vv['type'] == 2){ ?>
					 <th><?php echo $vv['name'];?></th>
					 <?php }?>
				 <?php }?>	
				 <th>合计</th>
				 <th>费用合计</th>
				 <th>手边题本成本</th>
				 <th>合计</th>
				 <th>不扣除成本收入</th>
				 <th>扣除成本收入</th>
				 <th>3686折合</th>
				 <th>2986折合</th>
				 <th>2986折合(不扣成本)</th>
				</tr>
		   </thead>
		   <tbody>
		   
			    <tr>
				<?php foreach($WeekInfo[$key]['books'] as $kk=>$vv){?>
				    <?php if($vv['type'] == 1){ ?>
					 <td><?php echo $vv['price_total'];?></td>
					  <?php }?>
				
				 <?php }?>
				<td><?php echo isset($WeekInfo[$key]['bookstotal'][1]['price_total']) ? $WeekInfo[$key]['bookstotal'][1]['price_total']+$WeekInfo[$key]['books'][16]['price_total'] : 0;?></td>
				<?php foreach($WeekInfo[$key]['books'] as $kk=>$vv){?>
				    <?php if($vv['type'] == 2){ ?>
					 <td><?php echo $vv['price_total'];?></td>
					  <?php }?>
				 <?php }?>
				  <td><?php echo $WeekInfo[$key]['bookstotal'][2]['price_total']??0;?></td>
				  <td><?php echo $WeekInfo[$key]['total']['books_price'];?></td>
				  <td><?php echo $WeekInfo[$key]['total']['book_priceTotal'];?></td>
				  <td><?php echo $WeekInfo[$key]['total']['book_priceTotal'];?></td>
				  <td><?php echo $WeekInfo[$key]['total']['price_total'];?></td>
				  <td><?php echo $WeekInfo[$key]['total']['sales_priceTotal'];?></td>
				  <td><?php echo $WeekInfo[$key]['total']['into_36'];?></td>
				  <td><?php echo $WeekInfo[$key]['total']['into_29'];?></td>
				  <td><?php echo $WeekInfo[$key]['total']['into_cost_29'];?></td>
				  <td><?php echo $WeekInfo[$key]['total']['sales_price'];?></td>
				  <td><?php echo $WeekInfo[$key]['total']['season_onePrice'];?></td>
				  <td><?php echo $WeekInfo[$key]['total']['book_onePrice'];?></td>
			  </tr>
		   </tbody>
		
	</table>
	</div>
</div>

<?php }?>
